﻿using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using TianYuan.Data.Dapper.Repositories;
using TianYuan.Data.Dapper.Uow;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TianYuan.Data.Dapper.Dependency
{
    /// <summary>
    /// Dapper工作单元和仓储模式注册器
    /// </summary>
    public class DapperDataInstaller : IWindsorInstaller
    {
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(
                //Component.For<IDbContext>().ImplementedBy<DbContextBase>().LifestylePerWebRequest(),
                Component.For<IUnitOfWork>().ImplementedBy<UnitOfWork>().LifestyleTransient(),
                Component.For<ICacheService>().ImplementedBy<HttpRuntimeCache>().Named("HttpRuntimeCache").LifestyleSingleton(),
                Component.For(typeof(IRepository<,>)).ImplementedBy(typeof(Repository<,>)).LifestyleTransient(),
                Component.For(typeof(IRepository<>)).ImplementedBy(typeof(Repository<>)).LifestyleTransient()
                );
        }
    }
}
